<template>
<div class="store view">
  <common-header />
  <div class="wrap app-center">
    <store-header :baseInfo="baseInfo" />
    <store-nav :curCate="curCate" @changeTab="changeTab"/>
<!--    <store-content :lists="productList"/>-->
    <div class="app-container store-content">
      <div class="product-module app-container">
        <div class="product-module-content">
          <div class="pro-container" v-for="(item, index) in productList" :key="index" @click="handleItemClick">
            <div class="product">
              <div>
                <div class="poster">
                  <img :src="item.mainimage">
                </div>
                <h2>${{ item.money }}</h2>
                <div class="product-res"> {{$t('CommonSaleNumber')}} {{item.sales_volume}}</div>
                <p> {{ item.name}}</p></div>
              <div class="product-footer">
                <div>
                  <i class="el-icon-shopping-cart-full"></i>
                  <span class="buy-btn"> {{$t('CommonProductBuy')}} </span>
                </div>
                <div><i class="el-icon-star-off"></i></div>
              </div>
            </div>
          </div>
        </div>
            <slot name="pagination">
              <common-pagination :page="pageTotal" :pageNo="pageNo" @pageClick="pageClick"/>
            </slot>
      </div>
    </div>
  </div>
  <common-footer />
</div>
</template>
<script setup>
import { ref } from 'vue'
import { shopInfo } from '@/api/index.js'
import { useRouter } from "vue-router";
import CommonHeader from "@/components/common/CommonHeader.vue";
import StoreHeader from "@/components/store/StoreHeader.vue";
import CommonFooter from "@/components/common/CommonFooter.vue";
import StoreNav from "@/components/store/StoreNav.vue";
import StoreContent from "@/components/store/StoreContent.vue";
import CommonPagination from "@/components/common/CommonPagination.vue";
const router = useRouter()
const id = router.currentRoute.value.query.id
const baseInfo = ref({})
const curCate = ref('live')
const pageNo = ref(1)
const pageTotal = ref(0)
const productList = ref([])
const getShopInfo = () => {
  shopInfo({
    ids: id,
    type: curCate.value,
    page: pageNo.value
  }).then(res => {
    baseInfo.value = res.data.shop
    productList.value = res.data.list.data
    pageTotal.value = res.data.list.last_page
  }).catch(err => {})
}
getShopInfo()
const changeTab = (tab) => {
  curCate.value = tab
  pageNo.value = 1
  getShopInfo()
}
const handleItemClick = () => {

}
const pageClick = (page) => {
  pageNo.value = page
  getShopInfo()
}
</script>
<style scoped>
.store .wrap {
  width: 100%;
  margin-top: -13px;
}
.store-content {
  padding: 27px 0 20px;
}
.pro-container:hover .product {
  border: 1px solid var(--color-main);
  transform: scale(1.1);
}
.product-module-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 165px));
  gap: 20px 14px;
  align-content: center;
}
.product {
  border: 1px solid var(--color-border);
  padding: 0px 8px 8px;
  border-radius: 5px;
  position: relative;
  transition: all 0.5s ease-in-out;
}

.product > div {
  cursor: pointer;
}
.product .discount {
  width: 31px;
  height: 32px;
  background: url("") 100% center / 100% no-repeat;
  position: absolute;
  top: 0px;
  right: 0px;
  text-align: center;
  font-size: 11px;
  color: rgb(255, 255, 255);
  font-weight: 500;
}

.product .product-res {
  font-family: Roboto;
  font-style: normal;
  font-weight: 400;
  font-size: 10px;
  line-height: 12px;
  color: rgb(153, 153, 153);
}
.product .poster {
  overflow: hidden;
}

.product .poster, .product img {
  width: 100%;
  max-width: 165px;
  height: 165px;
}

.product img {
  object-fit: contain;
}
.product h2 {
  font-size: 16px;
  color: var(--color-price);
  margin-bottom: 6px;
  font-weight: 500;
}

.product p {
  font-size: 14px;
  font-weight: 400;
  min-height: 40px;
  line-height: 1.5;
  color: var(--color-title);
  max-width: 138px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 6px 0px 15px;
}
.product-footer {
  justify-content: space-between;
}

.product-footer, .product-footer div {
  display: flex;
  align-items: center;
}

.product-footer .el-icon-shopping-cart-full {
  margin-right: 8px;
}

.product-footer .buy-btn {
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.discount {
  width: 31px;
  height: 32px;
  background: url() no-repeat 100%/100%;
  position: absolute;
  top: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #fff;
  font-weight: 500
}
</style>
